package com.lzh.thinkpet.filter;

import com.lzh.thinkpet.controller.IndexController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author lzh
 * @date 2019/1/22 - 9:17
 */
@WebFilter(filterName = "systemFilter",urlPatterns = "/")
public class SystemFilter implements Filter {

    private final static Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
//        System.out.println("SystemFilter------>>> init");
        logger.info("SystemFilter------>>> init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("SystemFilter----->>> dofilter");
        logger.info("SystemFilter----->>> dofilter");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
//        System.out.println("SystemFilter------>>>  destory");
        logger.info("SystemFilter------>>>  destory");
    }
}
